import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { rulesVO, rulesForm, rulesQuery } from '@/api/event/rules/types';

/**
 * 查询事件规则列表
 * @param query
 * @returns {*}
 */

export const listrules = (query?: rulesQuery): AxiosPromise<rulesVO[]> => {
  return request({
    url: '/event/rules/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询事件规则详细
 * @param eventRulesId
 */
export const getrules = (eventRulesId: string | number): AxiosPromise<rulesVO> => {
  return request({
    url: '/event/rules/' + eventRulesId,
    method: 'get'
  });
};

/**
 * 新增事件规则
 * @param data
 */
export const addrules = (data: rulesForm) => {
  return request({
    url: '/event/rules',
    method: 'post',
    data: data
  });
};

/**
 * 修改事件规则
 * @param data
 */
export const updaterules = (data: rulesForm) => {
  return request({
    url: '/event/rules',
    method: 'put',
    data: data
  });
};

/**
 * 删除事件规则
 * @param eventRulesId
 */
export const delrules = (eventRulesId: string | number | Array<string | number>) => {
  return request({
    url: '/event/rules/' + eventRulesId,
    method: 'delete'
  });
};

/**
 * 查询事件通知用户列表
 * @param eventRulesId
 */
export const selectnoticeuser = () => {
  return request({
    url: '/event/rules/selectNoticeUser',
    method: 'get'
  });
};